package com.erplan.swt.app.gx;


import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;

public class GxStatusBar {
	static Label statusBarTxt = null;

	public static void createStatusBar(){
		Gx.statusBarArea = new Composite(Gx.shell, SWT.NONE);
		Gx.statusBarArea.setLayoutData("wrap, w 100%, h 2%");
		//Gx.statusBarArea.setBackground(Gx.display.getSystemColor(SWT.COLOR_DARK_RED));
		{
			statusBarTxt = new Label(Gx.statusBarArea, SWT.BORDER);
			statusBarTxt.setText("Ready");
			statusBarTxt.setBounds(0, 0, Gx.shell.getSize().x, 13);
			//statusBarTxt.setLayoutData("wrap");
		}
	}

	static Listener armListener = new Listener() {
		public void handleEvent(Event event) {
			MenuItem item = (MenuItem) event.widget;
			statusBarTxt.setText(item.getText());
			statusBarTxt.update();
		}
	};
	static Listener showListener = new Listener() {
		public void handleEvent(Event event) {
			Menu menu = (Menu) event.widget;
			MenuItem item = menu.getParentItem();
			if (item != null) {
				statusBarTxt.setText(item.getText());
				statusBarTxt.update();
			}
		}
	};
	static Listener hideListener = new Listener() {
		public void handleEvent(Event event) {
			statusBarTxt.setText("");
			statusBarTxt.update();
		}
	};
}